package moe.oil.api.databaseAPI;

import moe.oil.dto.school.CommentsDTO;
import moe.oil.validation.grop.OnUpdate;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(name = "database-service", contextId = "commentsAPI")
public interface CommentsAPI {
    @GetMapping("/comments/{id}")
    public CommentsDTO findByIdComments(@PathVariable("id") Long id);

    // 查询全部评论
    @GetMapping("/comments/{page}/{size}")
    public List<CommentsDTO> findAllComments(@PathVariable("page") int page, @PathVariable("size") int size);

    // 添加评论 根据id 插入 school 查询是否做到全部数据显示
    @PostMapping
    public CommentsDTO saveComments(@Validated(OnUpdate.class) @RequestBody CommentsDTO commentsDto);

    // 根据ID删除评论
    @DeleteMapping("/comments/{id}")
    public int deleteByIdComments(@PathVariable("id") Long id);

    // 修改
    @PutMapping("/comments")
    public CommentsDTO updateComments(@Validated CommentsDTO commentsDto);

}
